﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="/bootstrap-3.4.1-dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body style="display:none;">
    <div class="container">

        <!-- 顶端的导航栏 -->
        <nav class="navbar navbar-default navbar-inverse" role="navigation">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">硅谷OA办公系统</a>
            </div>
            <div>
                <!--向左对齐-->
                <!--向右对齐-->
                <ul class="nav navbar-nav navbar-right" style="margin-right:10px">
                    <li class="dropdown">

                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img id="userimg" style="width:30px;" src="Static/img/girl.png" /> <span id="sname"></span> <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#">个人中心</a></li>
                            <li><a href="#">修改密码</a></li>
                            <li class="divider"></li>
                            <li><a href="javascript:void(0);" onclick="Out()">退出登录</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>

        <div class="row">

            <!-- 左边的菜单栏 -->
            <div class="col-md-2">
                <div id="menusbox" class="panel panel-default panel-primary">
                  

                    <!--<div class="panel-heading">公告管理</div>
                    <ul class="list-group">
                        <li class="list-group-item"><a target="myiframe" href="/Page//Users/Index.html">公告列表</a></li>
                        <li class="list-group-item"><a target="myiframe" href="/Page//Users/Add.html">发布公告</a></li>
                    </ul>-->
                </div>


            </div>

            <!-- 右边的子页面 -->
            <div class="col-md-10">
                <iframe name="myiframe" style="width:100%;height:500px;border:none;" ></iframe>
            </div>
        </div>

    </div>
    <script src="/Static/Script/jquery-3.7.0.min.js"></script>
    <script src="/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>

    <script type="text/javascript">

        //获取个人信息  
        $.get("/Ajax/UsersHandler.ashx?type=user", function (res) {
            //console.log(res);
            if (res.code == 1) {
                $("body").show();
                $("#sname").text(res.data.Name);
                if (res.data.Sex=="男") {
                    $("#userimg").attr("src","/Static/img/boy.png")
                }
            }
            //else {
            //    alert("未登录或者登录状态已经丢失！");
            //    //获取不到个人信息  没有登录  登录已经丢失
            //    location.href = "Login.html";
            //}
        })

        //获取菜单列表
        $.get("/Ajax/MenusHandler.ashx?type=menu", function (res) {
            //console.log(res);
            if (res.code == 1) {
                //循环将一级菜单加入列表
                res.data.forEach(function (v) {
                    if (v.ParentID==0) {
                        $('<div class="panel-heading">' + v.MenuName + '</div>').appendTo($("#menusbox"));

                        //二次循环将一级菜单下的二级菜单加入
                        var $ul = $('<ul class="list-group">').appendTo($("#menusbox"));
                        res.data.forEach(function (vv) {
                            //判断是否是当前一级菜单下属的二级菜单
                            if (vv.ParentID==v.MenuID) {
                                var $li = $('<li class="list-group-item"><a target="myiframe" href="' + vv.URL + '">' + vv.MenuName + '</a></li>').appendTo($ul);
                            }
                            
                        })
                    } 
                })
            } else {
                alert(res.msg);
                //获取不到个人信息  没有登录  登录已经丢失
                location.href = "Login.html";
            }
        })

        //退出
        function Out() {
            $.post("/Ajax/UsersHandler.ashx?type=out", function (res) {
                console.log(res);
                if (res.code == 1) {
                    alert("退出成功");
                    location.href = "Login.html";
                } else {
                    alert(res.msg);
                }
            })
        }
    </script>
</body>
</html>